package com.zlc.platform.config;

import com.zlc.platform.interceptor.WebInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 人员认证
 * @author zl
 */
@Configuration
public class WebInterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private ApplicationContext context;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        WebInterceptor webInterceptor = context.getBean(WebInterceptor.class);

        InterceptorRegistration registration = registry.addInterceptor(webInterceptor);

        registration.addPathPatterns("/**");

        //排除认证的接口路径
        registration.excludePathPatterns("/login");

    }


}
